/*
 * Copyright (C) 2009 Christoph Caks
 *
 * This file is part of GLWAK.
 *
 * GLWAK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * GLWAK is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with GLWAK.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * X11Context.h
 *
 *  Created on: 11.07.2009
 *      Author: Christoph Caks
 */


#ifndef X11CONTEXT_H_
#define X11CONTEXT_H_

#include "OpenGL.h"
#include "Context.h"
#include "x11/X11Window.h"

#include <X11/Xlib.h>

namespace glwak {

namespace priv {

class X11Context : public Context {
public:
	X11Context();
	X11Context( X11Context* _shareContext );
	X11Context( Window* _window );
	virtual ~X11Context();

// from Context
	void makeCurrent();
	void swapBuffers();
	void *getExtensionAddress( const char *_extension );

// from Disposable
	void dispose();

protected:
// from Initializeable
	void initializeImpl();

private:
	X11Window* window;
	Display* display;
	GLXContext context;

	// own methods
	GLXFBConfig* getFramebufferConfig( int& fbCount );
	XVisualInfo* getVisualFromFBConfig( GLXFBConfig );
	GLXContext initializeOldStyleContext();

};

} // namespace priv

} // namespace glwak

#endif /* X11CONTEXT_H_ */
